<%- include header.ejs%>


<div style="width: 65%;float: left;margin-top: 60px">
    <div style="background-color: white;border: 1px solid #ffffff;border-radius: 5px;">
        <div style="padding: 20px;padding-bottom: 0px">
            <div style="width: 12%;float: left">
                <img class="img-rounded" src="<%-data.publishUser.headSrc%>" style="width: 50px;height: 50px;">
            </div>
            <div style="width: 85%;float: left">
                <span style="font-size: x-large"><%- data.theme %></span>
                <span style="color: #bababa;float: right"><%-data.postDate.format("yyyy-MM-dd hh:mm:ss")%></span><br>
                <span style="color:#c3c3c3;line-height: 30px"><%=__('forumEntry').publisher%>：<a href="/partnerCenter?username=<%- data.publishUser.username %>"><%- data.publishUser.nickname%></a></span>
            </div>
            <div style="clear: both"></div>
            <div style="margin-top: 30px;font-size: larger;color: #5e5e5e"><%- data.content %></div>
            <div style="width:50px;height:30px;text-align:center;margin-top: 30px;background-color: #f3f1e6;-moz-border-radius: 5px;-webkit-border-radius: 5px;"><span style="line-height: 30px"><a href="#reply"><%=__('forumEntry').reply%></a></span></div>
        </div>
        <% replyDatas.forEach(function(replyData,index){ %>
        <div style="padding: 20px;padding-bottom: 0px">
            <hr style="margin-bottom: 10px">
            <div style="width: 12%;float: left">
                <img class="img-rounded" src="<%-replyData.replyUser.headSrc%>" style="width: 50px;height: 50px;">
            </div>
            <div style="width: 80%;float: left">
                <span><a href="/partnerCenter?username=<%- replyData.replyUser.username %>"><%- replyData.replyUser.nickname%></a></span>
                <span style="color: #bababa"><%=__('forumEntry').word%> <%- replyData.replyDate.format("yyyy-MM-dd hh:mm:ss")%></span>
                <span style="color: #5e5e5e">&nbsp;&nbsp;&nbsp;<a href="#addSchedule<%-replyData._id%>" data-toggle="modal"><%=__('forumEntry').reply%></a></span>
                <div class="modal hide fade" id="addSchedule<%-replyData._id%>">
                    <div class="modal-header">
                        <a href="#" class="close" data-dismiss="modal"></a>
                        <h4> @<%-replyData.replyUser.nickname %></h4>
                    </div>
                    <form class="form-horizontal" method="post" action="/secondReply">
                        <div class="modal-body">
                            <input type="hidden" name="replyId" value="<%- replyData._id %>">
                            <input type="hidden" name="userId" value="<%- replyData.replyUser._id %>">
                            <script id="ucontainer<%- replyData._id %>" name="content" type="text/plain"></script>
                        </div>
                        <div class="modal-footer">
                            <button type="submit" class="btn btn-primary"><%=__('forumEntry').reply%></button>
                        </div>
                    </form>
                </div>
                <!--<span style="float: right;color: #8c2d2d" onclick="loadSecondMessage();">回复条数(点击查看)：<%- replyData.secondReplyTotal %></span><br>-->
                <span style="color:#5e5e5e;line-height: 40px"><%- replyData.content %></span>
                <% if(replyData.secondReplys.length!=0){%>
                <div style="margin: 20px;border:1px #d67a02 solid;padding: 10px">
                <% replyData.secondReplys.forEach(function(secondReply,index){%>
                    <% if(secondReply.secondReplyUser.username!=secondReply.toUser.username){%>
                    <span><a href="/partnerCenter?username=<%- secondReply.secondReplyUser.username %>"><%- secondReply.secondReplyUser.nickname%></a> <%=__('forumEntry').reply%> <a href="/partnerCenter?username=<%- secondReply.toUser.username %>"><%- secondReply.toUser.nickname%></a></span>
                    <% }else{ %>
                    <span><a href="/partnerCenter?username=<%- secondReply.secondReplyUser.username %>"><%- secondReply.secondReplyUser.nickname%></a></span>
                    <% } %>
                    <span style="color: #bababa">于 <%- secondReply.date.format("yyyy-MM-dd hh:mm:ss")%></span>
                    <span style="color: #5e5e5e">&nbsp;&nbsp;&nbsp;<a href="#addSchedule<%-secondReply._id%>" data-toggle="modal"><%=__('forumEntry').reply%></a></span>
                    <div class="modal hide fade" id="addSchedule<%-secondReply._id%>">
                        <div class="modal-header">
                            <a href="#" class="close" data-dismiss="modal"></a>
                            <h4> @<%-secondReply.secondReplyUser.nickname %></h4>
                        </div>
                        <form class="form-horizontal" method="post" action="/secondReply">
                            <div class="modal-body">
                                <input type="hidden" name="replyId" value="<%- replyData._id %>">
                                <input type="hidden" name="userId" value="<%- secondReply.secondReplyUser._id %>">
                                <script id="seconducontainer<%- secondReply._id %>" name="content" type="text/plain"></script>
                            </div>
                            <div class="modal-footer">
                                <button type="submit" class="btn btn-primary"><%=__('forumEntry').reply%></button>
                            </div>
                        </form>
                    </div>
                    <script>
                        UE.getEditor('seconducontainer<%-secondReply._id %>',{
                            initialFrameWidth:520,
                            enableAutoSave:false,
                            initialFrameHeight:100,
                            saveInterval:60000,
                            toolbars: [[
                                'bold', //加粗
                                'italic', //斜体
                                'underline', //下划线
                                'strikethrough', //删除线
                                'subscript', //下标
                                'fontborder', //字符边框
                                'superscript', //上标
                                'time', //时间
                                'date', //日期
                                'emotion', //表情
                                'spechars', //特殊字符
                                'forecolor', //字体颜色
                                'backcolor'//背景色
                            ]],
                            maximumWords:500,
                            zIndex:99999
                        });
                    </script>
                    <span style="color:#5e5e5e;line-height: 40px;"><%- secondReply.content%></span>
                <% }) %>
                </div>
                <% } %>

            </div>
            <div style="clear: both"></div>
            <script>
                UE.getEditor('ucontainer<%-replyData._id %>',{
                    initialFrameWidth:520,
                    enableAutoSave:false,
                    initialFrameHeight:100,
                    saveInterval:60000,
                    toolbars: [[
                        'bold', //加粗
                        'italic', //斜体
                        'underline', //下划线
                        'strikethrough', //删除线
                        'subscript', //下标
                        'fontborder', //字符边框
                        'superscript', //上标
                        'time', //时间
                        'date', //日期
                        'emotion', //表情
                        'spechars', //特殊字符
                        'forecolor', //字体颜色
                        'backcolor'//背景色
                    ]],
                    maximumWords:500,
                    zIndex:99999
                });
            </script>
        </div>
        <% }) %>

    </div>
</div>
<div style="width: 25%;float: left;margin-left: 3%;margin-top: 50px">
    <div style="text-align:center;border-radius: 10px;background-color: #d77a01;height: 60px;">
        <a href="/post" target="_blank" style="text-decoration: none"><h3 style="color: white;line-height: 60px"><%=__('forumEntry').publish%></h3></a>
    </div>
    <div style="margin-top: 30px;">
        <form id="search">
            <div class="input-append" style="width: 85%">
                <input type="text" placeholder="<%=__('forumEntry').search%>"  name="search" style="width: 100%" onfocus="showborder(this);" onblur="hiddenborder(this)"><img src="/images/search.png" style="width: 30px;height: 30px;" onclick="searchsubmit();">
            </div>
        </form>
    </div>
    <div style="padding:1%;border: 1px solid #ffffff;-moz-border-radius: 10px;-webkit-border-radius: 10px;height: 260px;background-color: white;margin-top: 20px">
        <h4><span style="font-size: larger"><%=__('active').regular%></span></h4>
        <% users.forEach(function(user,index){%>
        <div style="width: 20%;float: left;text-align: center;margin-left: 2%;margin-top: 10px">
            <img class="img-rounded" src="<%-user.headSrc%>" style="width: 55px;height: 55px">
            <span style="display: block"><a href="/partnerCenter?username=<%- user.username %>"><%- user.nickname %></a></span>
        </div>
        <%})%>
        <div style="clear: both"></div>
    </div>
</div>

<div class="span12" style="margin-top: 50px">
    <div id="page1"></div>
</div>
<div style="clear: both;margin-top: 50px;">
    <form class="form-horizontal" action="/reply" method="post" style="border:1px #d67a02 solid;padding: 10px">
        <fieldset>
            <legend><%=__('post').r_content%></legend>
            <input type="hidden" value="<%- data._id %>" name="id">
            <div class="control-group">
                <div class="controls" style="margin-left: 15%">
                    <script id="ucontainer" name="content" type="text/plain"></script>
                </div>
            </div>
            <div class="control-group">
                <div class="controls" style="margin-left: 15%">
                    <button type="submit" class="btn btn-primary"><%=__('forumEntry').reply%></button>
                </div>
            </div>
            <a name="reply"></a>
            <div class="control-group">

                <div class="controls" style="border:2px #feff55 solid;width: 80%;padding: 10px;margin-left: 15%">

                    <%=__('post').m1%><br>
                    <%=__('post').m2%><br>
                    <%=__('post').m3%>

                </div>
            </div>
        </fieldset>
    </form>
</div>

<%- include footer.ejs%>
<script>
    function searchsubmit(){
        $("#search").submit();
    }
    function showborder(obj){
        obj.style.cssText="border:1px #D79114 solid;width: 100%";
    }
    function hiddenborder(obj){
        obj.style.cssText="width: 100%";
    }
    function submit(obj){
        obj.submit();
    }
    function test(){
//        alert($(window).height())       //可见区域高度
//        alert($(window).width())        //可见区域宽度
//        alert($(document).height())     //整个页面高度
//        alert($(document).width())      //整个页面宽度
        alert($(document).scrollTop())  //获取滚动条到顶部的垂直高度
    }
    $(function(){
        //获得浏览器参数

        $.extend({
            getUrlVars: function(){
                var vars = [];
                var hash;
                var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
                console.log(hashes);
                for(var i = 0; i < hashes.length; i++){
                    hash = hashes[i].split('=');
                    vars.push(hash[0]);
                    vars[hash[0]] = hash[1];
                }
                return vars;
            },
            getUrlVar: function(name){
                return $.getUrlVars()[name];
            }
        });

        //封装浏览器参数
        var composeUrlParams=function(){
            var param='';
            $.each($.getUrlVars(), function(i, item) {
                if(item!='num'){
                    var val=$.getUrlVar(item);
                    if(val) param += "&" + item+"="+val;
                }
            });
            return param;
        }
        var options = {
            currentPage:<%- page.num %>,                //当前页，css样式同其他页不同
            totalPages:<%- page.pageCount %>,           //总页数
            numberOfPages:5,                            //导航最多显示页数
            pageUrl: function(type, page, current) {    //页面跳转
                if(page!=<%- page.num %>){
                    return "/postParticulars?num="+ page+composeUrlParams();
                }

            }
        }
        $('#page1').bootstrapPaginator(options);
    })
</script>
<script type="text/javascript">

    var ue = UE.getEditor('ucontainer',{
        initialFrameWidth:650,
        enableAutoSave:false,
        initialFrameHeight:171,
        saveInterval:60000,
        maximumWords:5000,
        zIndex:950
    });

</script>